<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>IOT平台--register</title>
<link href="{{ url_for('static', filename='Wopop_files/style_log2.css') }}" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='Wopop_files/style.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='Wopop_files/userpanel.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='Wopop_files/jquery.ui.all.css') }}">

<script src="{{ url_for('static', filename='js/jquery-3.3.1.min.js') }}"></script>

</head>

<body class="login" mycollectionplug="bind">
<div class="login_m">
  <div class="login_logo"><img src="{{ url_for('static', filename='Wopop_files/login3.png') }}" width="235" height="56"></div>
  <div class="login_boder">

     <div class="login_padding" id="login_model">

       
        <h2>用户名</h2>
        <label>
            <input type="text" id="username" name="username" class="txt_input " required="required"  placeholder="请输入用户名！" >
        </label>

        <h2>密码</h2>
        <label>
            <input type="password" name="password" id="password" class="txt_input" required="required"  placeholder="请输入密码！">
        </label>

        <h2>再次确认</h2>
        <label>
            <input type="password" name="checknumber" id="checknumber" class="txt_input" required="required"  placeholder="请再输入一次！">
        </label>

        <p class="forgot"><a id="iforgot" href="/login">已有账户？去登录</a></p>

        <div class="rem_sub" >
          <!-- 登录-->          
              <input type="button" class="sub_button" name="submit" id="submit" value="注册" 
                style="opacity: 0.7;" >    
        </div>  
       
     </div>
  </div>

</div>
 <br><br><br>
<p align="center"> More Infomation <a href="http://www.nju.edu.cn/" >NJU</a> - Designed by <a href="" title="" target="_blank">WSW</a></p>







<!-- javascript代码-->
<script type="text/javascript">

$(document).ready(function(e){

$("#submit").click(function(){
  /*
   var UserName = document.forms["registerform"]["username"];
   var PassWord = document.forms["registerform"]["password"]; 
   var CheckNumber = document.forms["registerform"]["checknumber"];
  */

    // var url_address = "http://172.17.182.6:5000/"
    var url_address = "http://172.20.10.3:5000/"
    // var url_address = "http://172.19.145.95:5000/"

    var UserName = $("#username").val();
    var PassWord = $("#password").val();
    var CheckNumber = $("#checknumber").val();

    if(PassWord != CheckNumber){
      alert('password and checkword are not equal!');
      //PhoneNumber.value="";
      CheckNumber.value="";
      return false;  
    }
    else{

      //两次密码正确，则调用Ajax上传数据
      var uname = $("#username").val();
      var pnum = $("#password").val();
      var cnum = $("#checknumber").val();
      var registerjson={"u":uname,"p":pnum,"c":cnum};

    $.ajax({

        url: url_address + "register_check",
        //处理页面的路径
        data:JSON.stringify(registerjson),
        //传递的数据.提交数一般以json格式来写,key是自定义的,:后面的值 就是上面的值
        type:"POST",
        //数据的提交传递方式,GET,POST 最好用POST
        datatype:"TEXT",
        //返回值的类型,TEXT,JSON,XML三种类型可选
        success:function(data){
        //如果ajax执行成功,返回来调用success函数即回调函数,返回值以参数的形式返回
        
        if(data=="OK")
        {
            alert('Registration successful!')
            window.location.href="/login";
            //return true;
        }
        else
        {
            alert(data);
            //return false;
        }
        
        },

    });

    }
  
})
});

</script>




</body>
</html>